package com.sdy.dao.mysql;

import com.sdy.po.Product;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ProductMapper {

    List<Product> getAll();

    Boolean update(@Param("product")Product product);

    Boolean insert(@Param("product")Product product);

    Boolean delete(@Param("product")Product product);

    /**
     * 查一个不带具体规格的产品
     * @param id
     * @return
     */
    @Select("select id,name,unit,updateTime,summary,infomation from po_product where id=#{id} ")
    @Results({
            @Result(column = "id",property = "id"),
            @Result(column = "id",property = "specificationList", many = @Many(select = "com.sdy.dao.mysql.SpecificationMapper.getListByProductId") )
    })
    Product getAbstractOne(@Param("id")Integer id);

//    /**
//     * 查一个具体规格的产品
//     * @param id
//     * @param sid
//     * @return
//     */
//    @Select("select id,name,unit,updateTime,summary,infomation from po_product where id=#{id} ")
//    @Results({
//            @Result(column = "#{specificationId}", property = "specification",one = @One(select = "com.sdy.dao.mysql.SpecificationMapper.getOneById"))
//    })
//    Product getConcreteOne(@Param("id")Integer id,@Param("specificationId")Integer sid);
}
